﻿@model GolfLeague.ViewModels.ScheduleViewModel

<script type="text/javascript">
    $(document).ready(function () {
        $(".round_accordion").accordion({ active: @Model.ActiveRound, collapsible: true });
        $('#ScheduleList').buttonset();
    });
    $(function () {
        $("#CurrentScheduleID").change(function () {
            var scheduleID = $(this).val();
            
            if (scheduleID != '') {
                window.location = '/Schedule/Index/' + scheduleID;
            }
        });
    });

    $(function () {
        $('.Schedules').click(function (e) {
            e.preventDefault();
            var scheduleID = $(this).attr('id');
            scheduleID = scheduleID.replace('schedule-', '');
            
            if (scheduleID != '') {
                window.location = '/Schedule/ScheduleView/' + scheduleID;
            }
        });
    });

</script>
@{
    ViewBag.Title = "Index";
}


<h2>Schedules</h2>

<table>
    <tr>
        <td valign="top">
            <div id="ScheduleList">
            @foreach (var item in Model.Schedules)
            {
                <input type="radio" id="schedule-@item.ScheduleID" class="Schedules" @(Model.CurrentScheduleID == item.ScheduleID ? "checked=\"checked\"" : "") /><label for="schedule-@item.ScheduleID">@item.ScheduleName</label><br />
            }
            </div>
        </td>
        <td>
            <div class="round_accordion">    
            @foreach (var item in Model.Rounds)
            {
                <h3><a href="#">@String.Format("{0:MM/dd/yyyy}", item.Round.RoundDate) @item.Round.Course.CourseName: @item.Round.Side.SideName</a></h3>
                <div>
                    @Html.Partial("_MatchesView", item)
                </div>
            }
            </div>
        </td>
    </tr>
</table>